package com.rst.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rst.dao.SectionDAO;
import com.rst.dao.StudentDAO;
import com.rst.model.Section;

@Service
public class SectionService {

	@Autowired
	private SectionDAO sectionDAO;
	
	@Autowired
	private StudentDAO studentDAO;
	
	public Long save(Section section) {		
		return sectionDAO.saveSection(section);		
	}

	public void update(Section section, Long sectionId) {
		section.setSectionId(sectionId);
		sectionDAO.udateSections(section);		
	}

	public Section getSectionById(Long sectionId) {
		return sectionDAO.getSectionById(sectionId);
	}

	public List<Section> getSectionList() {
		return studentDAO.getClassAndSections();	
	}

	public String deleteSection(Long sectionId) {
		Section section = sectionDAO.getSectionById(sectionId);
		section.setStatus(Section.INACTIVE);
		sectionDAO.udateSections(section);
		return "success";
	}

	
}
